package com.example.myapplication;

import static android.content.ContentValues.TAG;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class TwoTeamScoring extends AppCompatActivity {
    TextView sa,sb;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_two_team_scoring);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            sa=findViewById(R.id.sa);
            sb=findViewById(R.id.sb);
            return insets;
        });
    }
    public int sca=0,scb=0;
    public void click(View btn){
        if(btn.getId()==R.id.btna1){
            sca+=1;
        }
        else if(btn.getId()==R.id.btna2){
            sca+=2;
        }
        else if(btn.getId()==R.id.btna3){
            sca+=3;
        }
        else if(btn.getId()==R.id.btnb1){
            scb+=1;
        }
        else if(btn.getId()==R.id.btnb2){
            scb+=2;
        }
        else if(btn.getId()==R.id.btnb3){
            scb+=3;
        }
        else{
            sca=0;
            scb=0;
        }
        sa.setText(String.valueOf(sca));
        sb.setText(String.valueOf(scb));
    }

    protected void onSaveInstanceState(Bundle outState){
        super.onSaveInstanceState(outState);
        String scorea=sa.getText().toString();
        String scoreb=sb.getText().toString();
        Log.i(TAG,"onSaveInstanceState:");
        outState.putString("teama_score",scorea);
        outState.putString("teamb_score",scoreb);
    }
}